const TILES_MAP = require("TileMap");

cc.Class({
    extends: cc.Component,

    properties: {
        tileAtlas : cc.SpriteAtlas
        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
    },

    // use this for initialization
    onLoad: function () {

    },

    init : function (index, moFlag, MJId) {
        this.node.getComponent(cc.Sprite).spriteFrame = this.tileAtlas.getSpriteFrame(TILES_MAP[MJId]);

        if(moFlag){
            this.node.position = cc.p(index * 57 + 20, 0);
        }else{
            this.node.position = cc.p(index * 57, 0);
        }
    }
});
